package com.zmzncs.lmtc.module.park.controller;


import com.zmzncs.lmtc.common.pojo.Rest;
import com.zmzncs.lmtc.common.util.RestUtil;
import com.zmzncs.lmtc.module.park.service.ParkEntranceService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.Map;

/**
 * <p>
 * 停车场-道闸 前端控制器
 * </p>
 *
 * @author 高博文
 * @since 2021-02-18
 */
@RestController
@RequestMapping("/park/park-entrance")
public class ParkEntranceController {

    @Autowired
    ParkEntranceService parkEntranceService;

    @ApiOperation(value = "停车场通道")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
            @ApiImplicitParam(paramType = "query",name = "parkId", value = "车场ID", required = true),
            @ApiImplicitParam(paramType = "query",name = "parkSource", value = "车场注册来源（1：泊链 2：咪网 3：道尔，4：腾达）", required = true),
    })
    @PostMapping(value = "getParkChannels")
    public Rest<Map<String,Object>> getParkChannels(@NotNull Long parkId, @NotNull Integer parkSource) {
        Map<String,Object> map = parkEntranceService.getDaoerChannels(parkId,parkSource);
        return RestUtil.success(map);
    }

    @ApiOperation(value = "停车场远程开闸")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
            @ApiImplicitParam(paramType = "query",name = "parkId", value = "车场ID", required = true),
            @ApiImplicitParam(paramType = "query",name = "parkSource", value = "车场注册来源（1：泊链 2：咪网 3：道尔，4：腾达）", required = true),
            @ApiImplicitParam(paramType = "query",name = "channelId", value = "roadWayCode 通道编号", required = true),
            @ApiImplicitParam(paramType = "query",name = "channelIdStatus", value = "1开启 2 关闭", required = true),
    })
    @PostMapping(value = "parkGateOnOff")
    public Rest<Map<String,Object>> parkGateOnOff(@NotNull Long parkId,@NotNull Integer parkSource, @NotNull String channelId, @NotNull Integer channelIdStatus) {
        Map<String,Object> map = parkEntranceService.parkGateOnOff(parkId,parkSource,channelId,channelIdStatus);
        return RestUtil.success(map);
    }


}

